package io.renren.modules.app.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.modules.app.service.GalleryService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.zheok.testing.entity.GalleryEntity;
import utils.R;
import io.renren.common.utils.PageUtils;



/**
 * 图库
 *
 * @author ææ¢
 * @email 2863751700@qq.com
 * @date 2022-07-31 19:06:13
 */
@RestController
@RequestMapping("testing/gallery")
public class GalleryController {
    @Autowired
    private GalleryService galleryService;

    /**
     * 列表
     */
    @RequestMapping("/list")
   // // //@RequiresPermissions("testing:gallery:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = galleryService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
   // // //@RequiresPermissions("testing:gallery:info")
    public R info(@PathVariable("id") Long id){
		GalleryEntity gallery = galleryService.getById(id);

        return R.ok().put("gallery", gallery);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
   // // //@RequiresPermissions("testing:gallery:save")
    public R save(@RequestBody GalleryEntity gallery){
		galleryService.save(gallery);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
   // // //@RequiresPermissions("testing:gallery:update")
    public R update(@RequestBody GalleryEntity gallery){
		galleryService.updateById(gallery);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
   // // //@RequiresPermissions("testing:gallery:delete")
    public R delete(@RequestBody Long[] ids){
		galleryService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
